/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package am.aua.renju.web.filldata;

import am.aua.renju.bussinesslayer.MoveData;
import am.aua.renju.bussinesslayer.NewGameInfo;
import am.aua.renju.bussinesslayer.gamelogic.GameLogic;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.Map;
import javax.servlet.ServletException;

/**
 *
 * @author Ara Yeritsian
 */
public class JoinGame {
    
    public static Data load(NewGameInfo newGameInfo, Map root)
            throws ServletException, IOException {        
        root.put("whitePlayerNick", newGameInfo.whiteNickname);
        root.put("blackPlayerNick", newGameInfo.blackNickname);
        return new Data("joinGame.html", root);
    }

    public static String loadAjaxPlay(GameLogic.GameLogicState gameLogicState) {
        Gson gson = new Gson();
        return gson.toJson(gameLogicState, am.aua.renju.bussinesslayer.gamelogic.GameLogic.GameLogicState.class);
    }

    public static String loadAjaxOpponentPlay(MoveData moveData) {
        Gson gson = new Gson();
        return gson.toJson(moveData,MoveData.class);
    }

    public static String loadAjaxJoinRequest(boolean isJoinRequest) {
        Gson gson = new Gson();
        return gson.toJson(isJoinRequest, Boolean.class);
    }
    
    public static String loadAjaxIsMyTurn(boolean isMyTurn){
        Gson gson = new Gson();
        return gson.toJson(isMyTurn,Boolean.class);
    }
}
